import { createStore, combineReducers, applyMiddleware, compose } from 'redux';
// 使得dispatch能够接收函数
import thunk from 'redux-thunk';
import reducers from './reducers';

const state = {
  //出发日期
  departDate: Date.now(),
  //到达日期
  arriveDate: Date.now(),
  //出发时间  从服务端获取数据
  departTimeStr: null,
  //到达时间
  arriveTimeStr: null,
  //出发车站
  departStation: null,
  //到达车站
  arriveStation: null,
  //车次
  trainNumber: null,
  //运行时间
  durationStr: null,
  //座次和售票渠道
  tickets: [],
  //小浮层弹出
  isSchedualVisible: false,
  //解析location的url参数
  searchParsed: false,
};
const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const store = createStore(
  combineReducers(reducers),
  //state的默认值
  state,
  composeEnhancers(applyMiddleware(thunk))
);
export default store;
